﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Principal;

/// <summary>
/// Summary description for CustomPrincipal
/// </summary>
public class CustomPrincipal : IPrincipal
{
    private CustomIdentity _identity;

    public CustomPrincipal(CustomIdentity identity)
	{
        _identity = identity;
	}

    public IIdentity Identity
    {
        get { return _identity; }
    }

    public bool IsInRole(string role)
    {
        ManageDatabase data = new ManageDatabase();
        string usersRole = data.GetUserType(Convert.ToInt32(_identity.Ticket.UserData));

        if (usersRole != null && usersRole != "")
        {
            if (usersRole.Equals(role))
            {
                return true;
            }
            else {
                return false;
            }
        }
        else {
            return false;
        }
    }
}